/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.graficaluna.service.otros;

import com.graficaluna.dao.otros.ClienteDAO;
import dto.ClienteDTO;
import java.util.List;

/**
 *
 * @author ralf
 */
public class ServicioCliente {
    
    
    public void grabarCliente(ClienteDTO p){
        try {
            ClienteDAO dao = new ClienteDAO(); 
            if(dao.obtenerClientePorId(p.getIdCliente())==null){              
                dao.insertarCliente(p);
            }else dao.actualizarCliente(p);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    
    public List<ClienteDTO> listarClientes(){
        try {
            ClienteDAO dao = new ClienteDAO();
            List<ClienteDTO> personas =dao.listarClientes();
            return personas;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    
     public void eliminarCliente(Long codigo){
        try {
            ClienteDAO dao = new ClienteDAO();
            dao.eliminarCliente(codigo);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
     
     public List<ClienteDTO> buscarClientesPorFiltro(String texto){
        try {
            ClienteDAO dao = new ClienteDAO();
            List<ClienteDTO> personas =dao.buscarClientesPorFiltro(texto);
            return personas;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    
}
